package com.cskaoyan.extend.override;

/*
           使用方法覆盖，解决模型鸭不可以飞行的问题

           方法覆盖的使用场景: 在子类中修改父类方法的行为
 */
public class Demo3Situation {

    public static void main(String[] args) {
        FirstTypeDuck firstTypeDuck = new FirstTypeDuck();
        firstTypeDuck.fly();


        SecondTypeDuck secondTypeDuck = new SecondTypeDuck();
        secondTypeDuck.fly();

        ModelDuck modelDuck = new ModelDuck();
        modelDuck.fly();


    }
}

class BaseDuck {

    /*
          呱呱叫
     */
    public void quack() {
        System.out.println("呱呱叫");
    }

    public void swim() {
        System.out.println("swimming");
    }

    public void fly() {
        System.out.println("飞行ing");
    }

}

class FirstTypeDuck  extends BaseDuck{

}

class SecondTypeDuck extends BaseDuck {

}

class ModelDuck extends BaseDuck {

    public void fly() {
    }

}
